import {
    IsBoolean,
    IsDate,
    IsEmail,
    IsEnum,
    Length,
    ValidateIf,
    Validator
  } from "class-validator";
  import { Column, Entity, OneToMany, OneToOne, PrimaryGeneratedColumn } from "typeorm";
  import { User } from "@src/apps/account/entities/user.entity"
  export const MAX_TITLE_LENGTH = 100;
  export const MAX_NAME_LENGTH = 64;
  @Entity("thesis")
  export class Thesis {
    @PrimaryGeneratedColumn()
    id: number;

    @Column("boolean", {default: false })
    @IsBoolean()
    hidden: boolean;
  
    @Column("varchar", { length: MAX_NAME_LENGTH })
    @Length(1, MAX_NAME_LENGTH)
    ChineseName: string;

    @Column("varchar", { length: MAX_NAME_LENGTH })
    @Length(1, MAX_NAME_LENGTH)
    EnglishName: string;

    @Column("varchar", { length: MAX_TITLE_LENGTH })
    @Length(1, MAX_TITLE_LENGTH)
    ChineseTitle: string;

    @Column("varchar", { length: MAX_TITLE_LENGTH })
    @Length(1, MAX_TITLE_LENGTH)
    EnglishTitle: string;

    @Column("date")
    @IsDate()
    Date: Date;

    @OneToOne(
      () => User,
      (user) => user.thesis
    )
    user: User;
  }